package com.hyq.learn.common.exception.errorcode;

/**
 * @author xiaoyuqin
 */
public enum CommonErrorCode implements ErrorCode {

    /* **客户端错误**
     * 状态码为4XX, 错误码为4XXX, 新增错误码从4014开始递增
     */
    CONSTRAIN_VIOLATION(400, 101, "Illegal parameter(s)"),


    /* **服务器错误**
     * 状态码为5XX, 错误码为5XXX, 已有旧错误码忽略
     */
    UNKNOWN_ERROR(500, 100, "Internal server error"),
    /**
     * 第三方服务错误
     */
    PARTNER_SERVICE_UNAVAILABLE_ERROR(503, 101, "PartnerServiceUnavailableException"),

    /*
        *******************
        *    业务处理异常   *
        *******************
     */
    /**
     * 接口请求IO异常
     */
    REQUEST_INTERRUPT(200, 5002, "Resource access exception"),

    /**
     * 业务错误码
     */
    PARTNER_ERROR(200, 7002, "Third-party errors"),
    /**
     * 数据不存在
     */
    DATA_DOES_NOT_EXIST(200, 7003, "Data does not exist"),

    /**
     * 内部服务调用错误
     */
    INTERNAL_ERROR(200, 2006, "internal service error"),

    ;

    private final Integer code;

    private final String message;

    private final Integer httpStatus;

    CommonErrorCode(Integer httpStatus, Integer code, String message) {
        this.code = code;
        this.httpStatus = httpStatus;
        this.message = message;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public Integer getHttpStatus() {
        return httpStatus;
    }
}
